/**
 * 本文件由尚数增量代码引擎生成
 * @author Shann <851188611@qq.com>
 */
import { Message } from "@arco-design/web-vue";
import * as bannerApi from "@/api/banner";

export async function getBanners(param?: any) {
  const response = await bannerApi.getBanners(param);
  if (response.code === 20000) {
    return response.data.banners;
  }
  return [];
}

export async function getBanner(param?: any) {
  const response = await bannerApi.getBanner(param);
  if (response.code === 20000) {
    return response.data.banner;
  }
  return {};
}

export async function saveBanner(param?: any) {
  const apiCall = param.id ? bannerApi.updateBanner : bannerApi.createBanner;
  const response = await apiCall({ ...param });
  if (response.code === 20000) {
    Message.success(param.id ? "更新成功" : "新增成功");
  }
}

export async function deleteBanner(param?: any) {
  const response = await bannerApi.deleteBanner(param);
  if (response.code === 20000) {
    Message.success("移除成功");
  }
}
